package no.hio.wsprovider.vo;


/**
 * Represents information about a product.
 * @author andreas
 * @version 1.0
 * 
 */
public class Product implements Identifier{
	
	private int productID;
	private double price;
	private String title;
	private String description;
	
	public Product()
	{
		title = description = "";
	}
	/* (non-Javadoc)
	 * @see no.hio.wsprovider.vo.Identifier#getIdentifier()
	 */
	public int getIdentifier()
	{
		return getProductID();
	}
	
	/**
	 * @return the productID
	 */
	public int getProductID() {
		return productID;
	}
	/**
	 * @param productID the productID to set
	 */
	public void setProductID(int productID) {
		this.productID = productID;
	}
	/**
	 * @return the price
	 */
	public double getPrice() {
		return price;
	}
	/**
	 * @param price the price to set
	 */
	public void setPrice(double price) {
		this.price = price;
	}
	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}
	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}
	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}
	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		//simple equals implementation.
		if(obj == this) return true;
		if(!(obj instanceof Product)) return false;
		
		Product comp = (Product) obj;
				 
		if(comp.getPrice() != this.getPrice()) return false;
		if(comp.getProductID() != this.getProductID()) return false;
		if(!comp.getTitle().equals(this.getTitle())) return false;
		if(!comp.getDescription().equals(this.getDescription())) return false;
		
		return true;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#clone()
	 */
	@Override
	public Object clone() {
		
		Product copy = new Product();
		copy.description = this.description;
		copy.price = this.price;
		copy.productID = this.productID;
		copy.title = this.title;
		return copy;
	}
	
	@Override
	public String toString()
	{
		StringBuffer retVal = new StringBuffer();
		
		retVal.append("ProductID: ");
		retVal.append(productID);
		retVal.append(" Title: ");
		retVal.append(title);
		retVal.append(" Price: ");
		retVal.append(price);
		retVal.append(" Description: ");
		retVal.append(description);
		
		
		return retVal.toString();
	}
	
	
	
}
